<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 反转链表
        function Node(val){
            this.value = val;
            this.next = null;
        }
        var head = new Node(0);
        let z = head
        for (let i = 1; i<10; i++) {
            z.next = new Node(i);
            z = z.next; 
        }
       

        let arr =[];
        var p = head
        while(p){
            arr.push(p.value)
            p = p.next;
        }

        p = head;
        while(p){
            // debugger;
            p.value = arr.pop();
            p = p.next
        }
        console.log(p)
        console.log(head);
        console.log(arr)
    </script>
</body>
</html>